package demo.replace.ifelse;

import java.util.Optional;

/**
 * 优化测试
 *
 * @author dingwen
 * @date 2021/08/15
 */
public class OptimizationTest {
    public static void main(String[] args) {
        charge(10000.0);
    }

    public static void charge(Double money){
        Recharge recharge = RechargeFactory.getInstance().getRecharge(money);
        Optional.ofNullable(recharge).orElseThrow(() -> new RuntimeException("充值处理策略获取异常"));
        System.out.println("recharge.recharge(money) = " + recharge.recharge(money));
    }
}
